package actionPattern.RespsbilityChain;

import actionPattern.RespsbilityChain.model.*;

import java.util.ArrayList;
import java.util.List;

public class ApprovalChain {

    public boolean execute(LeaveRequest leaveRequest) {
        List<IManager> managerList = new ArrayList<>();
        managerList.add(new FinacialOfficer());
        managerList.add(new Leader());
        managerList.add(new HR());

        for(IManager each : managerList) {
            if (!each.approve(leaveRequest)) {
                return false;
            }
        }
        return true;
    }
}
